/**
 * 抛出异常类
 * 继承自异常基类Error
 */

class HttpException extends Error{
    constructor(msg='服务器异常',errorCode=10000,code=400){
        super()
        this.msg = msg
        this.errorCode = errorCode
        this.code = code
    }
}

class ParameterException extends HttpException{
    constructor(msg='参数错误',errorCode = 10001,code=400){
        super()
        this.code = code
        this.msg = msg
        this.errorCode = errorCode
    }
}

class NotFound extends HttpException{
    constructor(msg='未找到',errorCode = 10002,code=404){
        super()
        this.code = code
        this.msg = msg
        this.errorCode = errorCode
    }
}
class AuthFailed extends HttpException{
    constructor(msg='授权失败',errorCode = 10003,code=405){
        super()
        this.code = code
        this.msg = msg
        this.errorCode = errorCode
    }
}

class Forbbiden extends HttpException{
    constructor(msg='禁止访问',errorCode = 10006,code=403){
        super()
        this.code = code
        this.msg = msg
        this.errorCode = errorCode
    }
}

module.exports = {
    HttpException,
    ParameterException,
    NotFound,
    AuthFailed,
    Forbbiden
}